Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add limit to ArrowReaderBuilder to push limit down to parquet reader #3633

Merged
merged 4 commits into from
Jan 30, 2023

Conversation

thinkharderdev
Copy link
Contributor

Which issue does this PR close?

Closes #3631

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the parquet Changes to the parquet crate label Jan 30, 2023
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly just some minor nits, for consistency I think we should apply this to the async reader also prior to merge, should be a simple copy-paste

I also wonder if we should allow specifying an offset, in addition to a limit 🤔

Self {
selectors: vec![
RowSelector::select(limit),
RowSelector::skip(total_rows.saturating_sub(limit)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RowSelector::skip(total_rows.saturating_sub(limit)),

This shouldn't be necessary, it will get removed by RowSelection::trim anyway. Does make me wonder if this method is even really needed 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I think the main thing it does is just to truncate a final select if needed, but it can be a lot simpler if we do not need to append a skip on the end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry wrong method, yeah I don't think it makes sense then

@@ -371,6 +382,35 @@ impl RowSelection {
self
}

/// Limit this [`RowSelection`] to only select `limit` rows
pub(crate) fn limit(mut self, mut limit: usize) -> Self {
let mut remaining = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be more simply implemented as

Self {
    selectors: intersect_row_selections(&self.selectors, &[RowSelector::select(limit)]),
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, RowSelection row count allow to less than file total row count 🤔.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intersect_row_selections is a bit weird. It doesn't seem to coalesce selections. Not sure if that is intentional or not.

@@ -453,6 +467,17 @@ impl<T: ChunkReader + 'static> ArrowReaderBuilder<SyncReader<T>> {
selection = Some(RowSelection::from(vec![]));
}

// If a limit is defined, apply it to the final `RowSelection`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to also do something similar for the async reader

thinkharderdev and others added 2 commits January 30, 2023 14:14
Co-authored-by: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com>
tustvold
tustvold previously approved these changes Jan 30, 2023
@@ -430,6 +432,17 @@ where
return Ok((self, None));
}

// If a limit is defined, apply it to the final `RowSelection`
if let Some(limit) = limit {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will apply the limit to each row group separately, instead of the entire file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right. Fixed this to track the limit across row groups.

@tustvold tustvold dismissed their stale review January 30, 2023 16:11

async reader limit wrong

@tustvold tustvold merged commit a76ea1c into master Jan 30, 2023
@tustvold
Copy link
Contributor

Thank you

@ursabot
Copy link

ursabot commented Jan 30, 2023

Benchmark runs are scheduled for baseline = 3057fa5 and contender = a76ea1c. a76ea1c is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Push limit down into ParquetRecordBatchStream
4 participants